#file1 = File.new("output/ms8_step0-1_100.dat", "r")
#file2 = File.new("output/yo8_step0-1_100.dat", "r")

#file1 = File.new("output/step-1.0/ms8.dat", "r")
#file2 = File.new("output/step-1.0/yo8.dat", "r")

#file1 = File.new("output/step-0.1/ms8.dat", "r")
#file2 = File.new("output/step-0.1/yo8.dat", "r")

file1 = File.new("output/step_diff/ms8.dat", "r")
file2 = File.new("output/step_diff/yo8.dat", "r")

counter = 0

res1 = Hash.new
res2 = Hash.new

while ((line1 = file1.gets) && (line2 = file2.gets))
  tmp = line1.split(',')
  res1[tmp[0]] = tmp[1]
  tmp = line2.split(',')
  res2[tmp[0]] = tmp[1]
end
file1.close
file2.close

diff  = Hash.new
diff1 = Hash.new
diff2 = Hash.new

res1.each_pair {|key, value|
  new_key = sprintf("%.2f", key.to_f)
  diff1[new_key] = res1[key].to_f
  #puts "#{new_key}, #{diff1[new_key]}"
}

res2.each_pair {|key, value|
  new_key = sprintf("%.2f", key.to_f)
  diff2[new_key] = res2[key].to_f
  #puts "#{new_key}, #{diff2[new_key]}"
}

diff1.each_pair {|key, value|
  if (diff1[key] && diff2[key])
    diff[key] = (diff1[key]-diff2[key])/100
  end
}

diff.keys.sort.each { |value|
  printf("%8.8f %8.8f\n", value, diff[value])
}
